# -*- coding: utf-8 -*-
# @Author : YPC
# @Time : 2024/1/27 17:59
# @Use :
import time

from urllib.parse import quote

import pandas as pd


def get_city_code(city: str):
    """
    获取城市对应的携程城市名，根据传入城市三字码去city_code检索
    :param city:城市三字码
    :return:城市名
    """
    city_data = {
        "A": [{"cityId": 59, "cityName": "澳门", "cityCode": "MFM"},
              {"cityId": 97, "cityName": "阿里", "cityCode": "NGQ"},
              {"cityId": 171, "cityName": "安康", "cityCode": "AKA"},
              {"cityId": 173, "cityName": "阿克苏", "cityCode": "AKU"},
              {"cityId": 175, "cityName": "阿勒泰", "cityCode": "AAT"},
              {"cityId": 177, "cityName": "安庆", "cityCode": "AQG"},
              {"cityId": 178, "cityName": "鞍山", "cityCode": "AOG"},
              {"cityId": 179, "cityName": "安顺", "cityCode": "AVA"},
              {"cityId": 000, "cityName": "安阳", "cityCode": "AYN"},
              {"cityId": 1658, "cityName": "阿尔山", "cityCode": "YIE"},
              {"cityId": 21269, "cityName": "阿拉善左旗", "cityCode": "AXF"},
              {"cityId": 21863, "cityName": "阿拉善右旗", "cityCode": "RHT"}],
        "B": [
            {"cityId": 1, "cityName": "北京", "cityCode": "BJS"},
            {"cityId": 1, "cityName": "北京", "cityCode": "PEK"},
            {"cityId": 1, "cityName": "北京", "cityCode": "PKX"},
            {"cityId": 141, "cityName": "包头", "cityCode": "BAV"},
            {"cityId": 189, "cityName": "北海", "cityCode": "BHY"},
            {"cityId": 197, "cityName": "保山", "cityCode": "BSD"},
            {"cityId": 199, "cityName": "白山", "cityCode": "NBS"},
            {"cityId": 1116, "cityName": "白城", "cityCode": "DBC"},
            {"cityId": 1140, "cityName": "百色", "cityCode": "AEB"},
            {"cityId": 2548, "cityName": "博乐", "cityCode": "BPL"},
            {"cityId": 3887, "cityName": "巴彦淖尔", "cityCode": "RLK"},
            {"cityId": 3966, "cityName": "巴中", "cityCode": "BZX"},
            {"cityId": 22031, "cityName": "毕节", "cityCode": "BFJ"},
            {"cityId": 000, "cityName": "蚌埠", "cityCode": "BFU"},

        ],
        "C": [{"cityId": 4, "cityName": "重庆", "cityCode": "CKG"},
              {"cityId": 28, "cityName": "成都", "cityCode": "CTU"},
              {"cityId": 28, "cityName": "成都", "cityCode": "TFU"},
              {"cityId": 137, "cityName": "长治", "cityCode": "CIH"},
              {"cityId": 000, "cityName": "长海", "cityCode": "CNI"},
              {"cityId": 158, "cityName": "长春", "cityCode": "CGQ"},
              {"cityId": 199, "cityName": "长白山", "cityCode": "NBS"},
              {"cityId": 201, "cityName": "常德", "cityCode": "CGD"},
              {"cityId": 202, "cityName": "赤峰", "cityCode": "CIF"},
              {"cityId": 206, "cityName": "长沙", "cityCode": "CSX"},
              {"cityId": 211, "cityName": "朝阳", "cityCode": "CHG"},
              {"cityId": 213, "cityName": "常州", "cityCode": "CZX"},
              {"cityId": 218, "cityName": "池州", "cityCode": "JUH"},
              {"cityId": 562, "cityName": "承德", "cityCode": "CDE"},
              {"cityId": 575, "cityName": "昌都", "cityCode": "BPX"},
              {"cityId": 21741, "cityName": "沧源", "cityCode": "CWJ"}],
        "D": [{"cityId": 6, "cityName": "大连", "cityCode": "DLC"},
              {"cityId": 11, "cityName": "敦煌", "cityCode": "DNH"},
              {"cityId": 000, "cityName": "大足", "cityCode": "DZU"},
              {"cityId": 36, "cityName": "大理", "cityCode": "DLU"},
              {"cityId": 93, "cityName": "迪庆", "cityCode": "DIG"},
              {"cityId": 136, "cityName": "大同", "cityCode": "DAT"},
              {"cityId": 221, "cityName": "丹东", "cityCode": "DDG"},
              {"cityId": 231, "cityName": "大庆", "cityCode": "DQA"},
              {"cityId": 234, "cityName": "达县", "cityCode": "DAX"},
              {"cityId": 236, "cityName": "东营", "cityCode": "DOY"},
              {"cityId": 3997, "cityName": "德宏", "cityCode": "LUM"},
              {"cityId": 1222, "cityName": "稻城", "cityCode": "DCY"},
              {"cityId": 234, "cityName": "达州", "cityCode": "DAX"},
              {"cityId": 2542, "cityName": "德令哈", "cityCode": "HXD"}],
        "E": [{"cityId": 245, "cityName": "恩施", "cityCode": "ENH"},
              {"cityId": 3976, "cityName": "鄂尔多斯", "cityCode": "DSN"},
              {"cityId": 7626, "cityName": "二连浩特", "cityCode": "ERL"},
              {"cityId": 21339, "cityName": "额济纳旗 ", "cityCode": "EJN"},
              {"cityId": 992, "cityName": "鄂州", "cityCode": "EHU"}],
        "F": [{"cityId": 251, "cityName": "佛山", "cityCode": "FUO"},
              {"cityId": 255, "cityName": "富蕴", "cityCode": "FYN"},
              {"cityId": 257, "cityName": "阜阳", "cityCode": "FUG"},
              {"cityId": 258, "cityName": "福州", "cityCode": "FOC"},
              {"cityId": 21943, "cityName": "抚远", "cityCode": "FYJ"}],
        "G": [{"cityId": 32, "cityName": "广州", "cityCode": "CAN"},
              {"cityId": 33, "cityName": "桂林", "cityCode": "KWL"},
              {"cityId": 38, "cityName": "贵阳", "cityCode": "KWE"},
              {"cityId": 132, "cityName": "格尔木", "cityCode": "GOQ"},
              {"cityId": 267, "cityName": "广元", "cityCode": "GYS"},
              {"cityId": 268, "cityName": "赣州", "cityCode": "KOW"},
              {"cityId": 321, "cityName": "固原", "cityCode": "GYU"},
              {"cityId": 720, "cityName": "高雄", "cityCode": "KHH"},
              {"cityId": 2155, "cityName": "光化", "cityCode": "LHK"},
              {"cityId": 750, "cityName": "广汉", "cityCode": "GHN"},
              {"cityId": 21862, "cityName": "果洛", "cityCode": "GMQ"}],
        "H": [{"cityId": 5, "cityName": "哈尔滨", "cityCode": "HRB"},
              {"cityId": 17, "cityName": "杭州", "cityCode": "HGH"},
              {"cityId": 000, "cityName": "呼伦贝尔", "cityCode": "XRQ"},
              {"cityId": 000, "cityName": "黄石", "cityCode": "HSQ"},
              {"cityId": 000, "cityName": "河池", "cityCode": "HCJ"},
              {"cityId": 000, "cityName": "花土沟", "cityCode": "HTT"},
              {"cityId": 000, "cityName": "霍林郭勒", "cityCode": "HUO"},
              {"cityId": 000, "cityName": "惠州", "cityCode": "HUZ"},
              {"cityId": 000, "cityName": "红原", "cityCode": "AHJ"},
              {"cityId": 000, "cityName": "黄骅", "cityCode": "HHA"},
              {"cityId": 000, "cityName": "淮安", "cityCode": "HIA"},
              {"cityId": 000, "cityName": "菏泽", "cityCode": "HZA"},
              {"cityId": 23, "cityName": "黄山", "cityCode": "TXN"},
              {"cityId": 42, "cityName": "海口", "cityCode": "HAK"},
              {"cityId": 58, "cityName": "香港", "cityCode": "HKG"},
              {"cityId": 103, "cityName": "呼和浩特", "cityCode": "HET"},
              {"cityId": 129, "cityName": "汉中", "cityCode": "HZG"},
              {"cityId": 142, "cityName": "海拉尔", "cityCode": "HLD"},
              {"cityId": 275, "cityName": "邯郸", "cityCode": "HDG"},
              {"cityId": 278, "cityName": "合肥", "cityCode": "HFE"},
              {"cityId": 281, "cityName": "黑河", "cityCode": "HEK"},
              {"cityId": 282, "cityName": "怀化", "cityCode": "HJJ"},
              {"cityId": 285, "cityName": "哈密", "cityCode": "HMI"},
              {"cityId": 294, "cityName": "和田", "cityCode": "HTN"},
              {"cityId": 578, "cityName": "黄岩", "cityCode": "HYN"},
              {"cityId": 297, "cityName": "衡阳", "cityCode": "HNY"}],
        "J": [{"cityId": 24, "cityName": "九江", "cityCode": "JIU"},
              {"cityId": 91, "cityName": "九寨沟", "cityCode": "JZH"},
              {"cityId": 144, "cityName": "济南", "cityCode": "TNA"},
              {"cityId": 000, "cityName": "建三江", "cityCode": "JSJ"},
              {"cityId": 000, "cityName": "酒泉", "cityCode": "CHW"},
              {"cityId": 000, "cityName": "吉安", "cityCode": "KNC"},
              {"cityId": 157, "cityName": "鸡西", "cityCode": "JXA"},
              {"cityId": 159, "cityName": "吉林", "cityCode": "JIL"},
              {"cityId": 305, "cityName": "景德镇", "cityCode": "JDZ"},
              {"cityId": 307, "cityName": "井冈山", "cityCode": "JGS"},
              {"cityId": 35, "cityName": "景洪", "cityCode": "JHG"},
              {"cityId": 317, "cityName": "佳木斯", "cityCode": "JMU"},
              {"cityId": 318, "cityName": "济宁", "cityCode": "JNG"},
              {"cityId": 326, "cityName": "嘉峪关", "cityCode": "JGN"},
              {"cityId": 327, "cityName": "锦州", "cityCode": "JNZ"},
              {"cityId": 218, "cityName": "九华山", "cityCode": "JUH"},
              {"cityId": 956, "cityName": "揭阳", "cityCode": "SWA"},
              {"cityId": 1143, "cityName": "加格达奇", "cityCode": "JGD"},
              {"cityId": 1158, "cityName": "金昌", "cityCode": "JIC"}],
        "K": [{"cityId": 34, "cityName": "昆明", "cityCode": "KMG"},
              {"cityId": 109, "cityName": "喀什", "cityCode": "KHG"},
              {"cityId": 166, "cityName": "克拉玛依", "cityCode": "KRY"},
              {"cityId": 329, "cityName": "库车", "cityCode": "KCA"},
              {"cityId": 330, "cityName": "库尔勒", "cityCode": "KRL"},
              {"cityId": 333, "cityName": "凯里", "cityCode": "KJH"},
              {"cityId": 3326, "cityName": "喀纳斯", "cityCode": "KJI"},
              {"cityId": 4130, "cityName": "康定", "cityCode": "KGT"}],
        "L": [{"cityId": 37, "cityName": "丽江", "cityCode": "LJG"},
              {"cityId": 41, "cityName": "拉萨", "cityCode": "LXA"},
              {"cityId": 100, "cityName": "兰州", "cityCode": "LHW"},
              {"cityId": 108, "cityName": "林芝", "cityCode": "LZY"},
              {"cityId": 139, "cityName": "临汾", "cityCode": "LFQ"},
              {"cityId": 348, "cityName": "龙岩", "cityCode": "LCX"},
              {"cityId": 350, "cityName": "洛阳", "cityCode": "LYA"},
              {"cityId": 353, "cityName": "连云港", "cityCode": "LYG"},
              {"cityId": 354, "cityName": "柳州", "cityCode": "LZH"},
              {"cityId": 355, "cityName": "泸州", "cityCode": "LZO"},
              {"cityId": 427, "cityName": "梁平", "cityCode": "LIA"},
              {"cityId": 569, "cityName": "临沂", "cityCode": "LYI"},
              {"cityId": 605, "cityName": "六盘水", "cityCode": "LPF"},
              {"cityId": 744, "cityName": "林西", "cityCode": "LXI"},
              {"cityId": 1236, "cityName": "临沧", "cityCode": "LNJ"},
              {"cityId": 000, "cityName": "荔波县", "cityCode": "LLB"},
              {"cityId": 000, "cityName": "吕梁", "cityCode": "LLV"},
              {"cityId": 000, "cityName": "陇南", "cityCode": "LNL"},
              {"cityId": 000, "cityName": "莲花山", "cityCode": "ZIY"},
              {"cityId": 000, "cityName": "澜沧", "cityCode": "JMJ"},
              {"cityId": 000, "cityName": "黎平", "cityCode": "HZH"},
              {"cityId": 000, "cityName": "庐山", "cityCode": "LUZ"},
              {"cityId": 348, "cityName": "连城", "cityCode": "LCX"}],
        "M": [{"cityId": 59, "cityName": "澳门", "cityCode": "MFM"},
              {"cityId": 150, "cityName": "牡丹江", "cityCode": "MDG"},
              {"cityId": 155, "cityName": "漠河", "cityCode": "OHE"},
              {"cityId": 370, "cityName": "绵阳", "cityCode": "MIG"},
              {"cityId": 1083, "cityName": "满洲里", "cityCode": "NZH"},
              {"cityId": 3053, "cityName": "梅州", "cityCode": "MXZ"},
              {"cityId": 3997, "cityName": "芒市", "cityCode": "LUM"},
              {"cityId": 5383, "cityName": "马公", "cityCode": "MZG"},
              {"cityId": 7808, "cityName": "马祖", "cityCode": "MFK"}],
        "N": [{"cityId": 12, "cityName": "南京", "cityCode": "NKG"},
              {"cityId": 82, "cityName": "南通", "cityCode": "NTG"},
              {"cityId": 375, "cityName": "宁波", "cityCode": "NGB"},
              {"cityId": 376, "cityName": "南昌", "cityCode": "KHN"},
              {"cityId": 000, "cityName": "嫩江", "cityCode": "NNN"},
              {"cityId": 377, "cityName": "南充", "cityCode": "NAO"},
              {"cityId": 380, "cityName": "南宁", "cityCode": "NNG"},
              {"cityId": 385, "cityName": "南阳", "cityCode": "NNY"},
              {"cityId": 1161, "cityName": "宁蒗", "cityCode": "NLH"},
              {"cityId": 3360, "cityName": "那拉提", "cityCode": "NLT"},
              {"cityId": 91804, "cityName": "南竿", "cityCode": "LZN"}],
        "P": [{"cityId": 1097, "cityName": "攀枝花", "cityCode": "PZI"},
              {"cityId": 3996, "cityName": "普洱", "cityCode": "SYM"},
              {"cityId": 0000, "cityName": "蓬莱", "cityCode": "PNJ"},
              # {"cityId": 19, "cityName": "普陀山", "cityCode": "HSN"},
              {"cityId": 5383, "cityName": "澎湖列岛", "cityCode": "MZG"}],
        "Q": [{"cityId": 7, "cityName": "青岛", "cityCode": "TAO"},
              {"cityId": 52, "cityName": "琼海", "cityCode": "BAR"},
              {"cityId": 147, "cityName": "秦皇岛", "cityCode": "BPE"},
              {"cityId": 149, "cityName": "齐齐哈尔", "cityCode": "NDG"},
              {"cityId": 399, "cityName": "且末", "cityCode": "IQM"},
              {"cityId": 404, "cityName": "庆阳", "cityCode": "IQN"},
              {"cityId": 406, "cityName": "泉州", "cityCode": "JJN"},
              {"cityId": 407, "cityName": "衢州", "cityCode": "JUZ"},
              {"cityId": 7708, "cityName": "黔江", "cityCode": "JIQ"},
              {"cityId": 20892, "cityName": "祁连", "cityCode": "HBQ"}],
        "R": [{"cityId": 92, "cityName": "日喀则", "cityCode": "RKZ"},
              {"cityId": 1106, "cityName": "日照", "cityCode": "RIZ"},
              {"cityId": 21737, "cityName": "若羌", "cityCode": "RQA"}],
        "S": [
            {"cityId": 2, "cityName": "上海", "cityCode": "SHA"},
            {"cityId": 2, "cityName": "上海", "cityCode": "PVG"},
            {"cityId": 000, "cityName": "莎车", "cityCode": "QSZ"},
            {"cityId": 000, "cityName": "膳善", "cityCode": "SXJ"},
            {"cityId": 000, "cityName": "韶关", "cityCode": "HSC"},
            {"cityId": 000, "cityName": "苏州", "cityCode": "SZV"},
            {"cityId": 000, "cityName": "三沙", "cityCode": "XYI"},
            {"cityId": 30, "cityName": "深圳", "cityCode": "SZX"},
            {"cityId": 43, "cityName": "三亚", "cityCode": "SYX"},
            {"cityId": 411, "cityName": "上饶", "cityCode": "SQD"},
            {"cityId": 426, "cityName": "石河子", "cityCode": "SHF"},
            {"cityId": 428, "cityName": "石家庄", "cityCode": "SJW"},
            {"cityId": 3996, "cityName": "思茅", "cityCode": "SYM"},
            {"cityId": 437, "cityName": "三明", "cityCode": "SQJ"},
            {"cityId": 328, "cityName": "沙市", "cityCode": "SHS"},
            {"cityId": 406, "cityName": "石狮", "cityCode": "JJN"},
            {"cityId": 956, "cityName": "汕头", "cityCode": "SWA"},
            {"cityId": 451, "cityName": "沈阳", "cityCode": "SHE"},
            {"cityId": 452, "cityName": "十堰", "cityCode": "WDS"},
            {"cityId": 657, "cityName": "神农架", "cityCode": "HPG"},
            {"cityId": 1111, "cityName": "邵阳", "cityCode": "WGN"},
            {"cityId": 1303, "cityName": "松原", "cityCode": "YSQ"}],
        "T": [{"cityId": 3, "cityName": "天津", "cityCode": "TSN"},
              {"cityId": 105, "cityName": "太原", "cityCode": "TYN"},
              {"cityId": 000, "cityName": "图木舒克", "cityCode": "TWC"},
              {"cityId": 455, "cityName": "塔城", "cityCode": "TCG"},
              {"cityId": 456, "cityName": "通化", "cityCode": "TNH"},
              {"cityId": 458, "cityName": "通辽", "cityCode": "TGO"},
              {"cityId": 464, "cityName": "天水", "cityCode": "THQ"},
              {"cityId": 468, "cityName": "唐山", "cityCode": "TVS"},
              {"cityId": 578, "cityName": "台州", "cityCode": "HYN"},
              {"cityId": 15, "cityName": "泰州", "cityCode": "YTY"},
              {"cityId": 617, "cityName": "台北", "cityCode": "TPE"},
              {"cityId": 1227, "cityName": "铜仁", "cityCode": "TEN"},
              {"cityId": 1819, "cityName": "腾冲", "cityCode": "TCZ"},
              {"cityId": 3847, "cityName": "台南", "cityCode": "TNN"},
              {"cityId": 3848, "cityName": "台东", "cityCode": "TTT"},
              {"cityId": 3849, "cityName": "台中", "cityCode": "RMQ"},
              {"cityId": 21811, "cityName": "吐鲁番", "cityCode": "TLQ"}],
        "W": [{"cityId": 13, "cityName": "无锡", "cityCode": "WUX"},
              {"cityId": 26, "cityName": "武夷山", "cityCode": "WUS"},
              {"cityId": 39, "cityName": "乌鲁木齐", "cityCode": "URC"},
              {"cityId": 475, "cityName": "潍坊", "cityCode": "WEF"},
              {"cityId": 477, "cityName": "武汉", "cityCode": "WUH"},
              {"cityId": 479, "cityName": "威海", "cityCode": "WEH"},
              {"cityId": 484, "cityName": "乌兰浩特", "cityCode": "HLH"},
              {"cityId": 487, "cityName": "万州", "cityCode": "WXN"},
              {"cityId": 491, "cityName": "温州", "cityCode": "WNZ"},
              {"cityId": 492, "cityName": "梧州", "cityCode": "WUZ"},
              {"cityId": 1133, "cityName": "乌海", "cityCode": "WUA"},
              {"cityId": 1342, "cityName": "文山", "cityCode": "WNH"},
              {"cityId": 000, "cityName": "巫山", "cityCode": "WSK"},
              {"cityId": 000, "cityName": "芜湖", "cityCode": "WHA"},
              {"cityId": 000, "cityName": "五大连池", "cityCode": "DTU"},
              {"cityId": 000, "cityName": "乌拉特", "cityCode": "WZQ"},
              {"cityId": 7518, "cityName": "乌兰察布", "cityCode": "UCB"}],
        "X": [
            {"cityId": 10, "cityName": "西安", "cityCode": "SIA"},
            {"cityId": 10, "cityName": "西安", "cityCode": "XIY"},
            {"cityId": 000, "cityName": "邢台", "cityCode": "XTW"},
            {"cityId": 000, "cityName": "兴城", "cityCode": "XEN"},
            {"cityId": 000, "cityName": "兴宁", "cityCode": "XIN"},
            {"cityId": 25, "cityName": "厦门", "cityCode": "XMN"},
            {"cityId": 35, "cityName": "西双版纳", "cityCode": "JHG"},
            {"cityId": 58, "cityName": "香港", "cityCode": "HKG"},
            {"cityId": 124, "cityName": "西宁", "cityCode": "XNN"},
            {"cityId": 494, "cityName": "西昌", "cityCode": "XIC"},
            {"cityId": 496, "cityName": "襄阳", "cityCode": "XFN"},
            {"cityId": 497, "cityName": "夏河", "cityCode": "GXH"},
            {"cityId": 500, "cityName": "锡林浩特", "cityCode": "XIL"},
            {"cityId": 510, "cityName": "信阳", "cityCode": "XAI"},
            {"cityId": 512, "cityName": "徐州", "cityCode": "XUZ"},
            {"cityId": 513, "cityName": "忻州", "cityCode": "WUT"},
            {"cityId": 93, "cityName": "香格里拉", "cityCode": "DIG"},
            {"cityId": 937, "cityName": "咸宁", "cityCode": "IUO"},
            {"cityId": 1139, "cityName": "兴义", "cityCode": "ACX"},
            {"cityId": 3360, "cityName": "新源", "cityCode": "NLT"}],
        "Y": [{"cityId": 15, "cityName": "扬州", "cityCode": "YTY"},
              {"cityId": 529, "cityName": "伊犁", "cityCode": "YIN"},
              {"cityId": 99, "cityName": "银川", "cityCode": "INC"},
              {"cityId": 110, "cityName": "延安", "cityCode": "ENY"},
              {"cityId": 140, "cityName": "运城", "cityCode": "YCU"},
              {"cityId": 514, "cityName": "宜宾", "cityCode": "YBP"},
              {"cityId": 515, "cityName": "宜昌", "cityCode": "YIH"},
              {"cityId": 517, "cityName": "伊春", "cityCode": "LDS"},
              {"cityId": 518, "cityName": "宜春", "cityCode": "YIC"},
              {"cityId": 523, "cityName": "延吉", "cityCode": "YNJ"},
              {"cityId": 527, "cityName": "榆林", "cityCode": "UYN"},
              {"cityId": 529, "cityName": "伊宁", "cityCode": "YIN"},
              {"cityId": 533, "cityName": "烟台", "cityCode": "YNT"},
              {"cityId": 536, "cityName": "义乌", "cityCode": "YIW"},
              {"cityId": 539, "cityName": "岳阳", "cityCode": "YYA"},
              {"cityId": 000, "cityName": "盐城", "cityCode": "YNZ"},
              {"cityId": 000, "cityName": "元谋", "cityCode": "YUA"},
              {"cityId": 000, "cityName": "玉树", "cityCode": "YUS"},
              {"cityId": 000, "cityName": "营口", "cityCode": "YKH"},
              {"cityId": 000, "cityName": "玉林", "cityCode": "YLX"},
              {"cityId": 970, "cityName": "永州", "cityCode": "LLF"}],
        "Z": [{"cityId": 19, "cityName": "舟山", "cityCode": "HSN"},
              {"cityId": 27, "cityName": "张家界", "cityCode": "DYG"},
              {"cityId": 000, "cityName": "中卫", "cityCode": "THY"},
              {"cityId": 31, "cityName": "珠海", "cityCode": "ZUH"},
              {"cityId": 547, "cityName": "湛江", "cityCode": "ZHA"},
              {"cityId": 550, "cityName": "张家口", "cityCode": "ZQZ"},
              {"cityId": 553, "cityName": "中山", "cityCode": "ZGN"},
              {"cityId": 555, "cityName": "昭通", "cityCode": "ZAT"},
              {"cityId": 556, "cityName": "中卫", "cityCode": "ZHY"},
              {"cityId": 558, "cityName": "遵义新舟", "cityCode": "ZYI"},
              {"cityId": 559, "cityName": "郑州", "cityCode": "CGO"},
              {"cityId": 663, "cityName": "张掖", "cityCode": "YZY"},
              {"cityId": 1135, "cityName": "扎兰屯", "cityCode": "NZL"},
              {"cityId": 282, "cityName": "芷江", "cityCode": "HJJ"},
              {"cityId": 669329, "cityName": "遵义茅台", "cityCode": "WMT"}]
    }
    for item in city_data.values():
        for city_info in item:
            if city_info['cityCode'] == city:
                return city_info['cityName']
            if city_info['cityName'] == city:
                return city_info['cityCode']


def qunar_auto(row):
    dep_city_code = row['出发']
    arr_city_code = row['到达']
    dep_date = row['出发日期']
    flight_no = row['航班号']

    if get_city_code(dep_city_code):
        dep_city = quote(get_city_code(dep_city_code))
    else:
        print(f"没有这个出发城市{dep_city_code}")
        return row
    if get_city_code(arr_city_code):
        arr_city = quote(get_city_code(arr_city_code))
    else:
        print(f"没有这个到达城市{arr_city_code}")
        return row
    auto_url = f"https://m.flight.qunar.com/ncs/page/flightdetail?startCity={dep_city}&destCity={arr_city}&startDate={dep_date}&code={flight_no}&from=f_athena_urban&cat=mobile.wap.ptflag.seckill&_firstScreen=1&_gogokid=12"
    row['链接'] = auto_url
    return row


if __name__ == '__main__':
    # 创建ExcelWriter对象
    writer = pd.ExcelWriter(r'D:\project\git\work\python-work\docs\new_zsq129.xlsx', engine='xlsxwriter')

    airline_df1 = pd.read_excel(r'D:\project\git\work\python-work\docs\CZ航线R舱数量低价舱.xlsx', sheet_name='0129-0208')
    airline_df2 = pd.read_excel(r'D:\project\git\work\python-work\docs\CZ航线R舱数量低价舱.xlsx', sheet_name='0209-0211')
    airline_df3 = pd.read_excel(r'D:\project\git\work\python-work\docs\CZ航线R舱数量低价舱.xlsx', sheet_name='0212-0229')

    # 合并三个表格成一个DataFrame对象
    combined_df = pd.concat([airline_df1, airline_df2, airline_df3])

    processed_df = combined_df.apply(qunar_auto, axis=1)

    # 设置每个Sheet页中数据的起始行数
    start_row = 0
    # 设置每个Sheet页中的数据行数
    chunk_size = 500

    # 遍历DataFrame对象，将每个chunk写入一个Sheet页
    for i in range(0, len(processed_df), chunk_size):
        # 获取当前chunk的结束行数
        end_row = min(i + chunk_size, len(processed_df))

        # 获取当前chunk的数据
        chunk_df = processed_df.iloc[i:end_row]

        # 将当前chunk写入到Sheet页中
        chunk_df.to_excel(writer, sheet_name=f'Sheet{i // chunk_size}', index=False)

    # 保存文件
    writer._save()

    # 将处理后的结果写入新文件
    # processed_df.to_excel(r'D:\project\git\work\python-work\docs\new_zsq129.xlsx', index=False)